Phase processing using an application of Linear programming

Scott Collis1 and Jonathan Helmus1
1:Argonne National Laboratory

This notebook gives an example of using a Py-ART module. In this case one of the earlier modules that uses a linear programming approach to retrieving the monotonically increasing propigation phase from the radar signal. First we import and load a (reduced to two tilts) ARM C-SAPR file from Oklahoma.


In [1]:
import pyart
from matplotlib import pyplot as plt
import numpy as np
%matplotlib inline
print pyart.__version__


1.0.0.dev-2ad842d

In [2]:
filename ='data/sgpcsaprppi_20110520095101.nc'
radar = pyart.io.read(filename)

Lets take a look what is inside!


In [3]:
print radar.fields.keys()


[u'differential_phase', u'cross_correlation_ratio', u'normalized_coherent_power', u'spectrum_width', u'reflectivity', u'differential_reflectivity', u'specific_differential_phase', u'velocity']

In [4]:
display = pyart.graph.RadarDisplay(radar)
fig = plt.figure(figsize = [15,10])
display.plot_ppi('reflectivity', vmin = -8, vmax =64)


Hello beam blockage and attenuation central! I do not think R(Z) would work well here! Lets take a look at phase..


In [5]:
fig = plt.figure(figsize = [15,10])
display.plot_ppi('differential_phase', vmin = -180, vmax =180)


Wow! That is a strong signal! But there are some complications like second trip echoes..


In [6]:
# Perform a Linear programming phase processing to get the conditionally
# fitted phase profile and sobel filtered KDP field

c_offset = - 3.42

gates = radar.range['data'][1] - radar.range['data'][0]
rge = 30.0 * 1000.0
ng = rge / gates


reproc_phase, sob_kdp = pyart.correct.phase_proc.phase_proc_lp(
    radar, c_offset, debug=True, nowrap=ng, min_ncp=0.6, min_rhv=0.8)

# in some sectors where there is not enough data the LP method fails.. find these and mask


Unfolding
Exec time:  1.46203494072
Doing  0
Doing  1

In [7]:
reproc_phase['data'][np.where(reproc_phase['data'] < 0.0)] = 0.0
radar.add_field('recalculated_diff_phase', sob_kdp)
radar.add_field('proc_dp_phase_shift', reproc_phase)

In [8]:
fig = plt.figure(figsize = [15,10])
display.plot_ppi('proc_dp_phase_shift', vmin = 0, vmax =400)



In [9]:
fig = plt.figure(figsize = [15,10])
display.plot_ppi('recalculated_diff_phase', vmin = -1, vmax =10)



In [10]:
spec_at, cor_z = pyart.correct.attenuation.calculate_attenuation(
    radar, c_offset, debug=True, ncp_min=0.4)

# again filter where the algorithm has failed due to lack of data
spec_at['data'][np.where(spec_at['data'] < 0.0)] = 0.0

radar.add_field('specific_attenuation', spec_at)
radar.add_field('corrected_reflectivity', cor_z)


Doing  0
Doing  1

In [11]:
fig = plt.figure(figsize = [15,10])
display.plot_ppi('specific_attenuation', vmin = 0, vmax =1)



In [12]:
R = 300.0 * (radar.fields['specific_attenuation']['data']) ** 0.89
rain_rate_data = np.ma.masked_where(np.logical_or(
    (radar.fields['normalized_coherent_power']['data'] < 0.4),
    (radar.fields['cross_correlation_ratio']['data'] < 0.8)), R)
radar.add_field_like('unfolded_differential_phase', 
                     'rain_rate_A', rain_rate_data)
rainrate = radar.fields['rain_rate_A']
rainrate['valid_min'] = 0.0
rainrate['valid_max'] = 400.0
rainrate['standard_name'] = 'rainfall_rate'
rainrate['long_name'] = 'rainfall_rate'
rainrate['least_significant_digit'] = 1
rainrate['units'] = 'mm/hr'
rainrate['comment'] = 'Rain rate calculated from specific_attenuation, R=300.0*specific_attenuation**0.89, note R=0.0 where norm coherent power < 0.4 or rhohv < 0.8'
mask = radar.fields['corrected_reflectivity']['data'].mask
# set masked values to 0 for a nicer plot
radar.fields['rain_rate_A']['data'][np.where(mask)]=0.0

In [13]:
fig = plt.figure(figsize = [15,10])
display.plot_ppi('rain_rate_A', vmin = 0, vmax =150)



In [14]:
fig = plt.figure(figsize = [15,10])
display.plot_ppi('rain_rate_A',sweep=1, vmin = 0, vmax =150)